package com.scut.dispatching_server.config;

import java.util.ArrayList;

public class GlobalVariables {
    /**0表示多对多分配，1表示基于强化学习的多对多分配*/
    public final static Integer DISPATCHING_STRATEGY = 1;
    public final static long REAL_TIME_LENGTH = 10 * 60;
    public final static int LINEAR_FINAL_ROUND_REWARD = -200;
    /**一条订单的看单时间可以从数据集中的最短响应时间得出*/
    public final static int WATCH_TIME_FOR_ONE_ORDER = 1;
    /**分单的时间窗口*/
    public final static int DISPATCHING_TIME_WINDOW = 20;
    /**响应时间分段*/
    public final static int[] RESPONSE_TIME_WINDOWS = {0, 9, 20};
    public final static int[] RESPONSE_TIME_BORDERS = {0, 9, 20, 10000};
    /**奖励最大值*/
    public final static int MAX_REWARD = 600;
    /**订单的失效时间*/
    public final static int EXPIRED_TIME = 120;
    public final static double POWER = 1;
    /**单轮优化每个订单的收益*/
    public final static ArrayList<Integer> GAIN = new ArrayList<Integer>();
    static {
        for(int second = 1; second < DISPATCHING_TIME_WINDOW + 1; second++){
            GAIN.add(MAX_REWARD - 5 * second);
        }
    }
    /**一秒内采样的精度*/
    public final static int SAMPLES_IN_ONE_SECOND = 10;
    /**奖励函数*/
    public final static ArrayList<Float> REWARD_FUNCTION = new ArrayList<Float>();
    /**初始化奖励函数*/
    static {
        for(int second = 1; second < EXPIRED_TIME + 1; second++){
            REWARD_FUNCTION.add((float)Math.round((MAX_REWARD - (MAX_REWARD/(Math.exp(POWER * Math.log(EXPIRED_TIME)))) * Math.exp(POWER * Math.log(second))) * 100)/100);
        }
    }
    public final static int UPPER_LIMIT_ONE_DRIVER_CAN_RECEIVE_ORDERS = 30;
    /**获取响应时间预测值的服务器地址*/
    public final static String SERVER_ADDRESS = "http://localhost";
    public final static int SERVER_START_PORT = 16800;
    public final static int SERVER_NUMBER = 2;
    /**获取值函数的服务器地址*/
    public final static String VALUE_FUNCTION_SERVER_ADDRESS = "http://localhost:16900/predict";
    public final static String DEMO_ADDRESS = "http://localhost:8080";
    public final static String DEMO_DEMAND_ADD_PATH = "/demand/add";
    public final static String DEMO_DEMAND_DELETE_PATH = "/demand/delete";
    public final static String DEMO_SUPPLIER_ADD_PATH = "/supplier/add";
    public final static String DEMO_SUPPLIER_DELETE_PATH = "/supplier/delete";
    public final static String DEMO_RE_ADD_PATH = "/relationship/add";
    public final static String DEMO_RE_UPDATE_PATH = "/relationship/update";
    public final static String DEMO_RE_DELETE_PATH = "/relationship/delete";
    public final static String ALIVE_DEMAND_SET_KEY = "alive_demands";
    public final static String ALIVE_SUPPLIER_SET_KEY = "alive_suppliers";
    public final static String ALIVE_RELATIONSHIPS_SET_KEY = "alive_relationships";
    public final static String ROUND_ANSWER_TIME_LIST = "round_answer_time";
    public final static String ROUND_SUCCESS_DEMAND_LIST = "round_success_demands";
    public final static String DEMAND_COUNT = "demand_count";
    public final static String EXPIRED_DEMAND_COUNT = "expired_demand_count";
    public final static String AVG_ANSWER_TIME_LIST = "answer_time_list";
    public final static String SUCCESS_RATE_LIST = "success_rate_list";
    public final static String AVG_ANSWER_TIME = "avg_answer_time";
    public final static String SUCCESS_DEMAND_COUNT = "success_demand_count";
    public final static String ROUND_DEMAND_COUNT = "round_demand_count";
    public static boolean isDispatchingBegin = false;
}
